﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dbPoll_Application.ViewModels.PollReportViewModel>" %>
<%@ Import Namespace="dbPoll_Application.Models" %>

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type='text/javascript'>
        google.load("visualization", '1', { 'packages': ['imagechart'] });
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1', { 'packages': ['corechart'] });
    </script>
<table><tr>
<h3><%=Model.name%></h3>

        <% if (Model.selectedEntities.Count == 0)
           {
               int j = 0;
               foreach (KeyValuePair<Question, IDictionary<String, int>> question in Model.responses)
               {
                     %>
                     <td width="250px"><%Html.RenderPartial("QuestionChart", question);%></td>
                     <%                     
                    j++;
                    if (j % 3 == 0)
                    {
                                %> </tr> <tr> <%
                    }

               }
           }
           else
           {
               int j = 0;
               ViewData["selectedEntities"] = Model.selectedEntities;
               foreach (KeyValuePair<Question, IDictionary<String, IDictionary<int,int>>> question in Model.filteredResponses)
               {
                     %>
                     <td><%Html.RenderPartial("QuestionChartFiltered", question);%></td>
                     <%                     
                    j++;
                    if (j % 2 == 0)
                    {
                                %> </tr><tr> <%
                    }

               }
           }                                 
        %>
        </tr></table>